﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sinacor.Servico.Bovespa.Movimento.Service.ServiceImplementation.Translator.BusinessEntityToDataContract
{   
    public class ConsultaAssessor
    {
        public List<DataContract.Response.AgenteResponse> ToAgenteResponse(List<BusinessEntity.Agente> from)
        {
            List<DataContract.Response.AgenteResponse> to = null;

            if (from != null)
            {
                to = new List<DataContract.Response.AgenteResponse>();

                foreach (BusinessEntity.Agente item in from)
                {
                    to.Add(ToAgenteResponse(item));
                }
            }

            return to;
        }

        private DataContract.Response.AgenteResponse ToAgenteResponse(BusinessEntity.Agente from)
        {
            DataContract.Response.AgenteResponse to = null;

            if (from != null)
            {
                to = new DataContract.Response.AgenteResponse();

                to.Codigo = from.Codigo;
                to.CodigoAssessor = from.CodigoAssessor;
                to.Nome = from.Nome;
            }

            return to;
        }

        public List<DataContract.Response.AssessorResponse> ToAssessorResponse(List<BusinessEntity.Assessor> from)
        {
            List<DataContract.Response.AssessorResponse> to = null;

            if (from != null)
            {
                to = new List<DataContract.Response.AssessorResponse>();

                foreach (BusinessEntity.Assessor item in from)
                {
                    to.Add(ToAssessorResponse(item));
                }
            }

            return to;
        }

        private DataContract.Response.AssessorResponse ToAssessorResponse(BusinessEntity.Assessor from)
        {
            DataContract.Response.AssessorResponse to = null;

            if (from != null)
            {
                to = new DataContract.Response.AssessorResponse();

                to.Codigo = from.Codigo;
                to.Nome = from.Nome;
            }

            return to;
        }

        public List<DataContract.Response.CorrespondenteResponse> ToCorrespondenteResponse(List<BusinessEntity.Correspondente> from)
        {
            List<DataContract.Response.CorrespondenteResponse> to = null;

            if (from != null)
            {
                to = new List<DataContract.Response.CorrespondenteResponse>();

                foreach (BusinessEntity.Correspondente item in from)
                {
                    to.Add(ToCorrespondenteResponse(item));
                }
            }

            return to;
        }

        private DataContract.Response.CorrespondenteResponse ToCorrespondenteResponse(BusinessEntity.Correspondente from)
        {
            DataContract.Response.CorrespondenteResponse to = null;

            if (from != null)
            {
                to = new DataContract.Response.CorrespondenteResponse();

                to.Codigo = from.Codigo;
                to.Nome = from.Nome;
            }

            return to;
        }

        public List<DataContract.Response.ConsultaAssessorResponse> ToConsultaAssessorResponse(List<BusinessEntity.ConsultaAssessor> from)
        {
            List<DataContract.Response.ConsultaAssessorResponse> to = null;

            if (from != null)
            {
                to = new List<DataContract.Response.ConsultaAssessorResponse>();

                foreach (BusinessEntity.ConsultaAssessor item in from)
                {
                    to.Add(ToConsultaAssessorResponse(item));
                }
            }

            return to;
        }

        private DataContract.Response.ConsultaAssessorResponse ToConsultaAssessorResponse(BusinessEntity.ConsultaAssessor from)
        {
            DataContract.Response.ConsultaAssessorResponse to = null;

            if (from != null)
            {
                to = new DataContract.Response.ConsultaAssessorResponse();

                to.CodigoAgente = from.CodigoAgente;
                to.CodigoAssessor = from.CodigoAssessor;
                to.CodigoCliente = from.CodigoCliente;
                to.CodigoCorrespondente = from.CodigoCorrespondente;
                to.ComissaoAgente = from.ComissaoAgente;
                to.ComissaoAssessor = from.ComissaoAssessor;
                to.CorretagemTotal = from.CorretagemTotal;
                to.DataMovimento = from.DataMovimento;
                to.Desconto = from.Desconto;
                to.TotalNegociacao = from.TotalNegociacao;
                to.ValorCorrespondente = from.ValorCorrespondente;
            }

            return to;
        }
    }
}
